package dryven.view.engine.parser.componentinvocation;

import dryven.view.engine.component.metadata.ViewComponentMetaDataStrategy;
import dryven.view.engine.expression.nodelisters.ExpressionNodeFactory;
import dryven.view.engine.parser.parts.ChildZonePart;
import dryven.view.engine.parser.parts.ComponentInvocationPart;
import dryven.view.engine.parser.scope.InstructionScope;

public class ComponentInvocationCompilationData {
	private ViewComponentMetaDataStrategy _strategy;
	private ChildZoneInitialization _currentChildZoneStatus = ChildZoneInitialization.Unintialized;
	private ComponentInvocationPart _componentPart;
	private int _elementDepth;
	
	public ComponentInvocationCompilationData(
			ViewComponentMetaDataStrategy strategy, int elementDepth, ComponentInvocationPart part) {
		super();
		_strategy = strategy;
		_elementDepth = elementDepth;
		_componentPart = part;
	}
	
	public boolean elementIsChildZone(int elementDepth, String qName) {
		if(elementDepth==_elementDepth+1) {
			for (String childZone : _strategy.getChildZonesForComponent()) {
				if(qName.equals(childZone)) {
					return true;
				}
			}
		}
		return false;
	}

	public ChildZonePart getOrAddChildZonePart(String name,
			InstructionScope parentScope, ExpressionNodeFactory expressionFactory) {
		return _componentPart.getOrAddChildZonePart(name, parentScope, expressionFactory);
	}
	
	public boolean isComponentEnd(int depth) {
		return depth == _elementDepth;
	}

	public ChildZoneInitialization getCurrentChildZoneStatus() {
		return _currentChildZoneStatus;
	}

	public void setCurrentChildZoneStatus(ChildZoneInitialization currentChildZoneStatus) {
		_currentChildZoneStatus = currentChildZoneStatus;
	}
	
	
}
